package main.resources;

import java.util.MissingResourceException;
import java.util.ResourceBundle;
import javax.swing.ImageIcon;

public class Resource 
{
	private static ResourceBundle bundle;
	
	private static ResourceBundle getBundle() 
	{
		if(bundle == null) bundle = ResourceBundle.getBundle(Resource.class.getPackage().getName() + ".ru");
		return bundle;
	}
	
	public static String getString(String key) 
	{
		try 
		{
			return getBundle().getString(key);
		}
		catch(MissingResourceException e) 
		{
			return key;
		}
	}
	
	public static ImageIcon getIcon(String fileName) {
		try 
		{
			System.out.println(Resource.class.getResource(fileName));
			return new ImageIcon(Resource.class.getResource(fileName));
		}
		catch(Exception e) 
		{
			return null;
		}
	}
}

